<template>
  <div class="lix-user">
    <LixCell label="手机号绑定" :value="user.mobile" isLink @tap="go2BindMobilePage"/>
    <LixCell label="关于" @tap="go2AboutPage" isLink/>
    <button open-type="getUserInfo" />
  </div>
</template>

<script>
import LixCell from '@/components/lix-cell';
import { USER_GET_INFO } from '../../store/mutation-types';
import { mapGetters, mapActions } from 'vuex';

export default {
  components: {
    LixCell
  },
  computed: {
    ...mapGetters('user', {
      user: 'user'
    })
  },
  data() {
    return {
    };
  },
  onLoad() {

  },
  methods: {
    ...mapActions('user', {
      getUserInfo: USER_GET_INFO
    }),
    go2BindMobilePage() {
      wx.navigateTo({
        url: '/pages/member/bindmobile'
      });
    },
    go2AboutPage() {
      wx.navigateTo({
        url: '/pages/member/about'
      });
    },
    getUserWechatInfo() {
      console.log('手机号绑定');
      wx.getSetting({
        success: (res) => {
          console.log(res);
          if (res.authSetting['scope.userInfo'] && res.authSetting['scope.userInfo'] === true) {
            console.log('有用户权限');
          } else {
            console.log('没有用户权限');
          }
        }
      });
      wx.getUserInfo({
        success: function(res) {
          var userInfo = res.userInfo;
          var nickName = userInfo.nickName;
          var avatarUrl = userInfo.avatarUrl;
          console.log(userInfo);
          console.log(nickName);
          console.log(avatarUrl);
        },
        fail: function(e) {
          console.log(e);
        }
      });
    },
    getSettingforUser() {
      wx.getSetting({
        success: (res) => {
          console.log(res);
          if (res.authSetting['scope.userInfo'] && res.authSetting['scope.userInfo'] === true) {
            console.log('有用户权限');
          } else {
            console.log('没有用户权限');
          }
        }
      });
    }
  }
};
</script>

<style lang="scss">
@import "../../theme-chalk/mixins/mixins";
@import "../../theme-chalk/_main";

page {
  min-height: 100%;
  background: #f5f5f5;
}
@include b(user) {
  padding-top: 10px;
  min-height: 100%;
  background: #f5f5f5;
  border-top: 1rpx solid #c7c7c7;
}
</style>
